// 导入express
const express = require('express');
// 实例化路由对象
const router = express.Router();
// 导入处理函数模块
const { addArticle, getArticles, updateArticleById, deleteArticleById } = require('../routerHandler/articlesHandler');

// 导入解析formdata的模块multer
const multer = require('multer');
// 上传
const upload = multer({ dest: __dirname + '/../uploads' });

// 导入验证模块
const expressJoi = require('@escook/express-joi');
// 导入验证规则
const { articlesSchema } = require('../schema/articlesSchema');

// 发布文章
router.post('/articles/add',upload.single('cover_img'), expressJoi(articlesSchema), addArticle)
// 获取文章
router.post('/articles/list', expressJoi(articlesSchema), getArticles)

// 导出文章路由模块
module.exports = router;